// This example shows how to read value of server's NamespaceArray, and display the namespace URIs in it. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . using System; using OpcLabs.EasyOpc.UA; using OpcLabs.EasyOpc.UA.AddressSpace.Standard; using OpcLabs.EasyOpc.UA.OperationModel; namespace UADocExamples._EasyUAClient { partial class ReadValue { public static void NamespaceArray() { UAEndpointDescriptor endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"; // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) // or "https://opcua.demo-this.com:51212/UA/SampleServer/" // Instantiate the client object var client = new EasyUAClient(); // Perform the operation: Obtain value of a node object value; try { value = client.ReadValue(endpointDescriptor, UAVariableIds.Server_NamespaceArray); // i=2255 } catch (UAException uaException) { Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message); return; } if (!(value is string[] arrayValue)) { Console.WriteLine("*** Not a string array"); return; } // Display results for (int i = 0; i < arrayValue.Length; i++) Console.WriteLine($"{i}: {arrayValue[i]}"); } // Example output: // //0: http://opcfoundation.org/UA/ //1: urn:DEMO-5:UA Sample Server //2: http://test.org/UA/Data/ //3: http://test.org/UA/Data//Instance //4: http://opcfoundation.org/UA/Boiler/ //5: http://opcfoundation.org/UA/Boiler//Instance //6: http://opcfoundation.org/UA/Diagnostics //7: http://samples.org/UA/memorybuffer //8: http://samples.org/UA/memorybuffer/Instance } }
# This example shows how to read value of server's NamespaceArray, and display the namespace URIs in it. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python . # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc # Import .NET namespaces. from System import * from OpcLabs.EasyOpc.UA import * from OpcLabs.EasyOpc.UA.AddressSpace.Standard import * from OpcLabs.EasyOpc.UA.OperationModel import * endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer') # or 'http://opcua.demo-this.com:51211/UA/SampleServer' (currently not supported) # or 'https://opcua.demo-this.com:51212/UA/SampleServer/' # Instantiate the client object. client = EasyUAClient() # Perform the operation: Obtain value of a node. try: value = IEasyUAClientExtension.ReadValue(client, endpointDescriptor, UANodeDescriptor(UAVariableIds.Server_NamespaceArray)) # i=2255 except UAException as uaException: print('*** Failure: ' + uaException.GetBaseException().Message) exit() if not isinstance(value, Array): print('*** Not an array') exit() arrayValue = value # Display results. for i, element in enumerate(arrayValue): print(i, ': ', element, sep='') print() print('Finished.')
' This example shows how to read value of server's NamespaceArray, and display the namespace URIs in it. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Imports OpcLabs.EasyOpc.UA Imports OpcLabs.EasyOpc.UA.AddressSpace.Standard Imports OpcLabs.EasyOpc.UA.OperationModel Namespace _EasyUAClient Partial Friend Class ReadValue Public Shared Sub NamespaceArray() ' Define which server we will work with. Dim endpointDescriptor As UAEndpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" ' or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported) ' or "https://opcua.demo-this.com:51212/UA/SampleServer/" ' Perform the operation: Obtain value of a node Dim client = New EasyUAClient() ' Obtain value of a node Dim value As Object Try value = client.ReadValue(endpointDescriptor, UAVariableIds.Server_NamespaceArray) ' i = 2255 Catch uaException As UAException Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message) Exit Sub End Try If TypeOf value IsNot String() Then Console.WriteLine("*** Not a string array") Exit Sub End If Dim arrayValue() As String = CType(value, String()) ' Display results For i = 0 To arrayValue.Length - 1 Console.WriteLine($"{i}: {arrayValue(i)}") Next i End Sub ' Example output ' '0: http://opcfoundation.org/UA/ '1: urn:DEMO-5:UA Sample Server '2: http://test.org/UA/Data/ '3: http://test.org/UA/Data'Instance '4: http://opcfoundation.org/UA/Boiler/ '5: http://opcfoundation.org/UA/Boiler'Instance '6: http://opcfoundation.org/UA/Diagnostics '7: http://samples.org/UA/memorybuffer '8: http://samples.org/UA/memorybuffer/Instance End Class End Namespace
Rem This example shows how to read value of server's NamespaceArray, and display the namespace URIs in it. Rem Rem Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . Option Explicit Const endpointDescriptorUrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer" ' Instantiate the client object Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient") ' Perform the operation On Error Resume Next Dim value: value = Client.ReadValue(endpointDescriptorUrlString, "i=2255") If Err.Number <> 0 Then WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description WScript.Quit End If On Error Goto 0 ' Work around the fact that elements of object arrays returned cannot be retrieved in VBScript directly. Dim ElasticVector: Set ElasticVector = CreateObject("OpcLabs.BaseLib.Collections.ElasticVector") ElasticVector.Assign(value) ' Display results Dim i: For i = ElasticVector.LowerBound To ElasticVector.UpperBound WScript.Echo i & ": " & ElasticVector(i) Next ' Example output: ' '0: http://opcfoundation.org/UA/ '1: urn:DEMO-5:UA Sample Server '2: http://test.org/UA/Data/ '3: http://test.org/UA/Data//Instance '4: http://opcfoundation.org/UA/Boiler/ '5: http://opcfoundation.org/UA/Boiler//Instance '6: http://opcfoundation.org/UA/Diagnostics '7: http://samples.org/UA/memorybuffer '8: http://samples.org/UA/memorybuffer/Instance
Copyright © 2004-2024 CODE Consulting and Development, s.r.o., Plzen. All rights reserved. Web page: www.opclabs.com
Send Documentation Feedback. Resources: Knowledge Base, Product Downloads. Technical support: Online Forums, FAQ.Missing some example? Ask us for it on our Online Forums! You do not have to own a commercial license in order to use Online Forums, and we reply to every post.